package vista;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

import controlador.Banco;

public class ventanaCC extends JFrame {

	private static final long serialVersionUID = 1L;
    private JButton btnNuevaCC;
    private JButton btnBajaCC;
    private JButton btnBuscarCC;
    private JButton btnDepositar;
    private JButton btnExtraer;
    private JPanel panel;
    private Banco banco;
    
    public ventanaCC(Banco ba){
    	super();
    	this.banco=ba;
    	cargarVentana();
    	escucharEventos();
    }

	private void escucharEventos() {
		
		btnNuevaCC.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent evt){
                    ventanaNuevaCC vNC = new ventanaNuevaCC(banco);
                    vNC.setVisible(true);
            }
		});
        
		btnDepositar.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent evt){
            	ventanaDespositar vD=new ventanaDespositar(banco);
            	vD.setVisible(true);
            }
		});
 
		btnExtraer.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent evt){
            	ventanaExtraer vD=new ventanaExtraer(banco);
            	vD.setVisible(true);
            }
		});
		btnBuscarCC.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent evt){
            	ventanaBuscarCC vD=new ventanaBuscarCC(banco);
            	vD.setVisible(true);
            }
		});
	}

	private void cargarVentana() {
		
		setSize(400,300);
        setTitle("Pantalla Principa - Banco");
        setResizable(false);
        setVisible(true);
        btnNuevaCC = new JButton("Nueva Cuenta");
        btnNuevaCC.setBounds(100, 30, 140, 25);
        btnBajaCC = new JButton("Baja Cuenta");
        btnBajaCC.setBounds(100, 60, 140, 25);
        btnBuscarCC = new JButton("Buscar Cuenta");
        btnBuscarCC.setBounds(100, 90, 140, 25);
        btnDepositar = new JButton("Depositar");
        btnDepositar.setBounds(100, 120, 140, 25);
        btnExtraer = new JButton("Extraer");
        btnExtraer.setBounds(100, 150, 140, 25);
        panel = new JPanel();
        panel.setBounds(getBounds());
        panel.setLayout(null);
        panel.add(btnNuevaCC);
        panel.add(btnBajaCC);
        panel.add(btnBuscarCC);
        panel.add(btnDepositar);
        panel.add(btnExtraer);
        this.add(panel);	
	}
    
}
